package com.nbsaas.boot.store.rest.convert;

import com.nbsaas.boot.store.data.entity.StoreCheckInRecord;
import com.nbsaas.boot.store.api.domain.response.StoreCheckInRecordResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
* 场馆入场记录-实体对象转化成响应对象
*/

public class StoreCheckInRecordResponseConvert  implements Converter<StoreCheckInRecordResponse,StoreCheckInRecord> {

    @Override
    public StoreCheckInRecordResponse convert(StoreCheckInRecord source) {
        StoreCheckInRecordResponse  result = new  StoreCheckInRecordResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getCustomer()!=null){
                    result.setCustomerPhone(source.getCustomer().getPhone());
                    }

                    try {
                        if(source.getStore()!=null){
                            result.setStoreName(source.getStore().getName());
                        }
                    } catch (Exception ignored) { }

                    if(source.getStore()!=null){
                        result.setStore(source.getStore().getId());
                    }

                    try {
                        if(source.getCustomer()!=null){
                            result.setCustomerName(source.getCustomer().getName());
                        }
                    } catch (Exception ignored) { }

                    if(source.getCustomer()!=null){
                        result.setCustomer(source.getCustomer().getId());
                    }
        return result;
    }

}

